package com.servlet;

import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;

import com.bean.BaseBean;
import com.dao.DBDao;

public class Dwr {
	
	DBDao dbDao = new DBDao();
	
	public List<BaseBean> getProv() {
		List<BaseBean> list = new ArrayList<BaseBean>();
		String sql = "select provinceID, province from hat_province";
		ResultSet rs = dbDao.excuteSelect(sql);
		try {
			while(rs.next()) {
				list.add(new BaseBean(rs.getString("provinceID"), rs.getString("province")));
			}
		} catch (SQLException e) {
			e.printStackTrace();
		}
		return list;
	}
	
	
	public List<BaseBean> getCity(String provid) {
		List<BaseBean> list = new ArrayList<BaseBean>();
		String sql = "select cityID, city from hat_city where father = " + "'" + provid + "'";
		ResultSet rs = dbDao.excuteSelect(sql);
		try {
			while(rs.next()) {
				list.add(new BaseBean(rs.getString("cityID"), rs.getString("city")));
			}
		} catch (SQLException e) {
			e.printStackTrace();
		}
		return list;
	}
	
	
	public List<BaseBean> getArea(String cityid) {
		List<BaseBean> list = new ArrayList<BaseBean>();
		String sql = "select areaID, areas from hat_area where father = " + "'" + cityid + "'";
		ResultSet rs = dbDao.excuteSelect(sql);
		try {
			while(rs.next()) {
				list.add(new BaseBean(rs.getString("areaID"), rs.getString("areas")));
			}
		} catch (SQLException e) {
			e.printStackTrace();
		}
		return list;
	}
}
